from copy import copy, deepcopy
# == :判断的是值
# is ：判断的是地址

num1 = -6
num2 = -6
print(id(num1), id(num2))
print(num1 == num2)
print(num1 is num2)

'''
小整数对象：[-5,256]
最好在python环境中演示，pycharm进行了其他的优化
'''
print("=============")
a = [1, 2, 3, 4, 5, [1, 2, 3]]
b = a
print(a == b)
print(b is a)
# 深浅拷贝区分的前提是列表中有无其他列表
# 浅拷贝：只拷贝表层元素
# copy
print("==========")
c = copy(a)
print(c)
print(c == a)
print(c is a)

# 深拷贝：在内存中重新创建所有子元素
# deepcopy
print("================")
d = deepcopy(a)
print(d == a)
print(d is a)

print(id(a[1]), id(c[1]), id(d[1]))
print(id(a), id(c), id(d))

print(id(a[5]), id(c[5]), id(d[5]))
print(id(a[5][1]), id(c[5][1]), id(d[5][1]))
